﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WellBuilt.Model;

namespace WellBuilt.Service
{
    public class PlatFormService
    {
        internal static PlatFormOut PlatFormResult(PlatFormIn platFormIn)
        {
            PlatFormOut platFormOut = new PlatFormOut();

            double a = platFormIn.PTB_Width;
            double α1 = platFormIn.WJ_α1;
            double α2 = platFormIn.WJ_α2;
            double α3 = platFormIn.WJ_α3;
            double β = platFormIn.MD_β;
            //钢材强度
            platFormOut.SteelStrength = (platFormIn.SteelMarks == "Q345") ? 310 : 215;
            //平台荷载
            double ptfh = platFormIn.PlatformLoad;
            //平台板厚度
            double ptbhd = platFormIn.PTB_Thicknessorm;
            double Mx = α1 * ptfh * 1.4 * Math.Pow(a, 2);
            double My = α2 * ptfh * 1.4 * Math.Pow(a, 2);
            double Mxy = α3 * ptfh * 1.4 * Math.Pow(a, 2);
            double Mmax = (Mx > My ? Mx : My) > Mxy ? Mx > My ? Mx : My : Mxy;
            double σmax = 6 * Mmax / (1.2 * Math.Pow(ptbhd / 1000, 2)) / 1000;
            double νmax = β * 1.4 * ptfh * Math.Pow(a, 4) / (206000 * Math.Pow(ptbhd / 1000, 3)) / 1000;
            platFormOut.WJ_Mx = Mx;
            platFormOut.WJ_My = My;
            platFormOut.WJ_Mxy = Mxy;
            platFormOut.WJ_Mmax = Mmax;
            platFormOut.MD_νmax = νmax;
            platFormOut.QD_σmax = σmax;
            platFormOut.QD_Checking = σmax < platFormOut.SteelStrength ? "强度OK" : "强度No";
            
            platFormOut.MD_Checking = νmax < a / 150 ? "挠度OK" : "挠度NO";

            return platFormOut;
        }
    }
}
